package com.lwc.backendsinglestructure.strategy.registerStrategy;

import com.lwc.backendsinglestructure.domain.dto.user.RegisterForm;
import com.lwc.backendsinglestructure.strategy.RegisterStrategy;

/**
 * 工厂 + 策略 + 抽象模板方法提高代码复用性、可扩展性
 * 通用注册服务
 */
public abstract class BaseRegisterStrategy implements RegisterStrategy {

    /**
     * 抽象方法
     * @param registerForm
     * @return
     */
    @Override
    public Boolean register(RegisterForm registerForm) {
        preValidate(registerForm);
        // 具体实现类实现逻辑
        return doRegister(registerForm);
    }

    /**
     * 注册参数前置处理
     * @param registerForm
     */
    protected abstract void preValidate(RegisterForm registerForm);


    /**
     * 具体实现注册
     *
     * @param registerForm
     * @return
     */
    protected abstract Boolean doRegister(RegisterForm registerForm);
}
